<?php

namespace app\index\controller;
use Firebase\JWT\JWT;
use think\Controller;
use think\facade\Session;
use think\Request;

class Login{
    public function index()
    {

        $Login = new \app\index\model\Login();
        try {
            $user = $Login->login();
            Session::set('user',$user);
            return ['status' => true, $user, 'token'=>JWT::encode($user,config('jwt_key'))];
        } catch (\Exception $e) {
            return ['status' => false, 'error' => $e->getMessage()];
        }
    }
}
